#include "BtreePlusPageNumberAllocator.h"


BtreePlusPageNumberAllocator::BtreePlusPageNumberAllocator()
:next(1)
{
}
BtreePlusPageNumberAllocator::~BtreePlusPageNumberAllocator(){
    freeList.clear();
}
PageNumberType BtreePlusPageNumberAllocator::nextPageNo(){
    if(freeList.size() > 0){
        PageNumberType pageNo = freeList.front();
        freeList.pop_front();
        return pageNo;
    }
    return next++;
}
void BtreePlusPageNumberAllocator::free(PageNumberType pageNo){
    assert(pageNo < next);
    //assert check : pageNo not in freeList
    freeList.push_back(pageNo);
}
